/* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
        limitations under the License.
==============================================================================*/

#ifndef COMMON_H
#define COMMON_H

#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>

#include "acl/acl.h"

namespace AclnnLazyAdam {
#define SUCCESS 0
#define FAILED 1

#define INFO_LOG(fmt, args...) fprintf(stdout, "[INFO]  " fmt "\n", ##args)
#define WARN_LOG(fmt, args...) fprintf(stdout, "[WARN]  " fmt "\n", ##args)
#define ERROR_LOG(fmt, args...) fprintf(stderr, "[ERROR]  " fmt "\n", ##args)

    /**
     * @brief Read data from file
     * @param [in] filePath: file path
     * @param [out] fileSize: file size
     * @return read result
     */
    bool ReadFile(const std::string &filePath, size_t fileSize, void *buffer, size_t bufferSize);

    /**
     * @brief Write data to file
     * @param [in] filePath: file path
     * @param [in] buffer: data to write to file
     * @param [in] size: size to write
     * @return write result
     */
    bool WriteFile(const std::string &filePath, const void *buffer, size_t size);
}
#endif // COMMON_H
